how to count occurrences of each character in string in java